package com.example.pei.ithinklearnt.view.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.pei.ithinklearnt.R;
import com.example.pei.ithinklearnt.adapter.MatchedUserAdapter;
import com.example.pei.ithinklearnt.adapter.base.OnRecyclerViewListener;
import com.example.pei.ithinklearnt.bean.UserSkill;
import com.example.pei.ithinklearnt.view.base.BaseActivity;
import com.example.pei.ithinklearnt.view.base.IMutlipleItem;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class MatchedFriendsActivity extends BaseActivity {


    @BindView(R.id.matched_contain)
    RecyclerView RvMatchedContain;

    ArrayList <UserSkill>  data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_matched_friends);

        data=(ArrayList <UserSkill>)getIntent().getSerializableExtra("result");


        IMutlipleItem<UserSkill> mutlipleItem = new IMutlipleItem<UserSkill>() {

            @Override
            public int getItemViewType(int position, UserSkill c) {
                return 0;
            }

            @Override
            public int getItemLayoutId(int viewtype) {
                return R.layout.item_matched;
            }

            @Override
            public int getItemCount(List<UserSkill> list) {
                return list!=null?list.size():0;
            }
        };
        MatchedUserAdapter adapter = new MatchedUserAdapter(this, mutlipleItem, null);
        adapter.setOnRecyclerViewListener(new OnRecyclerViewListener() {
            @Override
            public void onItemClick(View v, int position) {

                Bundle bundle = new Bundle();
                bundle.putInt("pos",1);
                bundle.putSerializable("u", data.get(position).getUser());
                startActivity(UserInfoActivity0.class, bundle,false);

            }

            @Override
            public boolean onItemLongClick(View v, int position) {
                return false;
            }
        });
        RvMatchedContain.setAdapter(adapter);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        RvMatchedContain.setLayoutManager(layoutManager);
        adapter.bindDatas(data);
    }

    @OnClick(R.id.button_backward)
    void back(){
        finish();
    }
}
